package com.lxm.ymcc.mq.lister.consumer;

import com.lxm.ymcc.service.ICourseOrderService;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
//topic-order-cancel:tags-order-cancel
@RocketMQMessageListener(topic = "topic-order-cancel",
        selectorExpression="tags-order-cancel"	//tags
        ,consumerGroup = "order-cancel-consumer"
        ,messageModel = MessageModel.BROADCASTING ) //消息的消费模式 CLUSTERING：集群    BROADCASTING：广播
public class OrderCancelConsumer implements RocketMQListener<MessageExt> {



    @Autowired
    private ICourseOrderService courseOrderService;
    @Override
    public void onMessage(MessageExt message) {
        byte[] body = message.getBody();
        //数据的转换
        String orderSn= new String(body);
        //取消本地的订单状态
        courseOrderService.cancelOrder(orderSn);

    }
}
